//
//  RedRecordTableViewCell.m
//  智积分
//
//  Created by Cynic on 2018/7/31.
//  Copyright © 2018年 Cynic. All rights reserved.
//

#import "RedRecordTableViewCell.h"

@implementation RedRecordTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    /*@property (nonatomic ,retain)UILabel *totalCentLabel;
     @property (nonatomic ,retain)UILabel *totalRedNumLabel;
     @property (nonatomic ,retain)UILabel *totalRedGetLabel;
     @property (nonatomic ,retain)UILabel *time;
     @property (nonatomic ,retain)UIButton *detailBtn;*/
    
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectZero];
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.layer.cornerRadius = 5;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(10);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(120);
    }];
    
    CGFloat wid = cx_wid - 24;
    CGFloat partwid = wid / 3;
    NSArray *titles = @[@"积分总额",@"红包总数",@"领取总数"];
    for (NSInteger index = 0; index < 3; index ++) {
        UIButton *partBtn = [[UIButton alloc] initWithFrame:CGRectZero];
        if (index == 0) {
            _totalCentBtn = partBtn;
        }
        else if (index == 1){
            _totalRedNumBtn = partBtn;
        }
        else if (index == 2){
            _totalRedGetBtn = partBtn;
        }
        [partBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [bgView addSubview:partBtn];
        partBtn.namelabel = [[UITextField alloc]initWithFrame:CGRectZero];
        [partBtn addSubview:partBtn.namelabel];
        partBtn.titleLabel.font = [UIFont systemFontOfSize:20];
        [partBtn.namelabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(0);
            make.bottom.mas_equalTo(-18);
            make.left.right.mas_equalTo(0);
        }];
        partBtn.namelabel.text = titles[index];
        partBtn.namelabel.textColor = [UIColor ColorWithHex:@"999A9C" withAlpha:1];
        partBtn.namelabel.font = [UIFont systemFontOfSize:13];
        partBtn.namelabel.textAlignment = NSTextAlignmentCenter;
        [partBtn setTitle:@"100" forState:UIControlStateNormal];
        [partBtn setTitleEdgeInsets:UIEdgeInsetsMake(-20, 0, 0, 0)];
        partBtn.titleLabel.font = [UIFont systemFontOfSize:20];
        partBtn.namelabel.font = [UIFont systemFontOfSize:13];
        
        [partBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(partwid * index);
            make.top.mas_equalTo(0);
            make.height.mas_equalTo(80);
            make.width.mas_equalTo(partwid);
        }];
    }
    
    UIView *centerLayer = [[UIView alloc] initWithFrame:CGRectZero];
    [bgView addSubview:centerLayer];
    centerLayer.backgroundColor = bggrayColor;
    [centerLayer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(80);
        make.height.mas_equalTo(1);
    }];
    
    _time = [[UILabel alloc] initWithFrame:CGRectZero];
    _time.textColor = [UIColor ColorWithHex:@"999999" withAlpha:1];
    _time.font = [UIFont systemFontOfSize:13];
    [bgView addSubview:_time];
    [_time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(partwid / 2 - 26);
        make.width.mas_equalTo(150);
        make.height.mas_equalTo(18);
        make.bottom.mas_equalTo(-11);
    }];
    
    _detailBtn = [[UIButton alloc] initWithFrame:CGRectZero];
    _detailBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [_detailBtn setTitle:@"领取详情" forState:UIControlStateNormal];
    _detailBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
    [_detailBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 0, 0, partwid / 2 - 26)];
    [_detailBtn setTitleColor:[UIColor ColorWithHex:@"4A90E2" withAlpha:1] forState:UIControlStateNormal];
    [bgView addSubview:_detailBtn];
    [_detailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(40);
    }];
    
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
